home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / AmigaTalk_X / intuition / BOOPSI.st < prev    next >
Encoding:
Text File  |  2002-03-13  |  8.8 KB  |  219 lines

  1. " -------------------------------------------------------------------- "
  2. " The Boopsi Class implements the AmigaTalk to BOOPSI functions.       "
  3. " I'm NOT going to document how existing BOOPSI classes are imple-     "
  4. " mented, you'll have to find that information from someone else!      "
  5. ""
  6. " See BOOPSIComms.st & BOOPSIMethodIDs.st for special tags used by the "
  7. " BOOPSI system & look at the BoopsiClassNames Class below this Class. "
  8. " -------------------------------------------------------------------- "
  9.  
  10. Class Boopsi :Object ! private rastPortObj iclassObj !
  11. [
  12.    dispose 
  13.       " You eventually free the object using this method: "
  14.       <primitive 238 0 private>.
  15.  
  16.       private <- nil.
  17.  
  18.       ^ nil
  19. |      
  20.    newBoopsiObject: classIDString in: iclassObject tags: tagArray
  21.       " This is the general method of creating objects from 'boopsi' classes.
  22.       * ('Boopsi' stands for "basic object-oriented programming system for
  23.       * Intuition".)
  24.       * 
  25.       * You specify a class either as iclassObject (for a private class) or
  26.       * by its ID string (for public classes).  If iclassObject is nil,
  27.       * then the classID is used.  See BoopsiClassNames below.
  28.       * 
  29.       * You further specify initial "create-time" attributes for the
  30.       * object via a TagItem list, and they are applied to the resulting
  31.       * generic data object that is returned.  The attributes, their meanings,
  32.       * attributes applied only at create-time, and required attributes
  33.       * are all defined and documented on a class-by-class basis.
  34.       *
  35.       * RETURNS
  36.       * A boopsi object, which may be used in different contexts such
  37.       * as a gadget or image, and may be manipulated by generic functions.
  38.       * You eventually free the object using the dispose method.
  39.       "
  40.       ^ private <- <primitive 238 1 iclassObject classIDString tagArray>
  41. |      
  42.    xxxAddBoopsiClass
  43.       " You don't need to call this method, makeClass:for:id:size:flags: 
  44.       * will take care of it for you!
  45.       "
  46.       <primitive 238 2 iclassObj>
  47. |      
  48.    removeBoopsiClass
  49.       " Makes a public class unavailable for public consumption.
  50.       * It's OK to call this function for a class which is not
  51.       * yet in the internal public class list, or has been
  52.       * already removed.
  53.       "
  54.       <primitive 238 3 iclassObj>
  55. |      
  56.    freeBoopsiClass ! success !
  57.       success   <- <primitive 238 4 iclassObj>.
  58.       
  59.       iclassObj <- nil. " Too late!  It's all gone! "
  60.       
  61.       ^ success         " Returns true if successful "
  62. |      
  63.    makeBoopsiClass: classID for: superClassObj id: superClassID size: size flags: flags
  64.       " Make your own BOOPSI Class.  classID & superClassID can be nil,
  65.       * (which indicates a private BOOPSI Class).  superClassObj
  66.       * should NEVER be nil.  size is the size of the instance data
  67.       * that your class's objects will require, beyond that data defined 
  68.       * for your superclass's objects.  flags should be zero for now 
  69.       * (unless you KNOW otherwise): 
  70.       "
  71.       iclassObj <- <primitive 238 5 classID superClassID superClassObj size flags>.
  72.  
  73.       self xxxAddBoopsiClass.
  74.  
  75.       ^ iclassObj
  76. |
  77.    obtainGIRPort: gadgetInfoObject  
  78.       " Sets up a RastPort for use (only) by custom gadget hook routines.
  79.       * This function must be called EACH time a hook routine needing
  80.       * to perform gadget rendering is called, and must be accompanied
  81.       * by a corresponding call to releaseGIRPort.
  82.       *
  83.       * Note that if a hook function passes you a RastPort pointer,
  84.       * e.g., GM_RENDER, you needn't call obtainGIRPort in that case.
  85.       "
  86.       ^ rastPortObj <- <primitive 238 6 gadgetInfoObject>
  87. |
  88.    releaseGIRPort
  89.       " Release a custom gadget RastPort Object from obtainGIRPort: "
  90.       <primitive 238 7 rastPortObject>
  91. |
  92.    getAttribute: attrID from: object into: storageObj
  93.       ^ <primitive 238 8 attrID object storageObj>
  94. |
  95.    setAttributes: anObject tags: tagArray 
  96.       " Specifies a set of attribute/value pairs with meaning as
  97.       * defined by a 'boopsi' object's class.
  98.       *
  99.       * This function does not provide enough context information or
  100.       * arbitration for boopsi gadgets which are attached to windows
  101.       * or requesters.  For those objects, use setGadgetAttributes:from:req:tags:
  102.       *
  103.       * The object does whatever it wants with the attributes you provide.
  104.       * The return value tends to be non-zero if the changes would require
  105.       * refreshing gadget imagery, if the object is a gadget.
  106.       "
  107.       ^ <primitive 238 9 anObject tagArray>
  108. |
  109.    setGadgetAttributes: gadObj from: winObj req: reqObj tags: tagArray
  110.       " Same as setAttributes:tags:, but provides context information and
  111.       * arbitration for classes which implement custom Intuition gadgets.
  112.       *
  113.       * You should use this function for boopsi gadget objects which have
  114.       * already been added to a requester or a window, or for "models" which
  115.       * propagate information to gadget(s) already added.
  116.       *
  117.       * Typically, the gadgets will refresh their visuals to reflect
  118.       * changes to visible attributes, such as the value of a slider,
  119.       * the text in a string-type gadget, the selected state of a button.
  120.       *
  121.       * You can use this as a replacement for setAttributes:tags:, too,
  122.       * if you specify nil for the 'winObj' and 'reqObj' parameters.
  123.       *
  124.       * The return value tends to be non-zero if the changes would require
  125.       * refreshing gadget imagery, if the object is a gadget.
  126.       "
  127.       ^ <primitive 238 10 gadObj winObj reqObj tagArray>
  128. |
  129.    nextObject: fromObject 
  130.       " This function is for boopsi class implementors only.
  131.       *
  132.       * When you collect a set of boopsi objects on an Exec List
  133.       * structure by invoking their OM_ADDMEMBER method, you
  134.       * can (only) retrieve them by iterations of this method.
  135.       *
  136.       * Works even if you remove and dispose the returned list
  137.       * members in turn.
  138.       " 
  139.       ^ <primitive 238 11 fromObject>
  140. |
  141.    doGadgetMethod: gadObj from: winObj req: reqObj message: msgObj
  142.       " Same as the DoMethod() function of amiga.lib, but provides context
  143.       * information and arbitration for classes which implement custom
  144.       * Intuition gadgets.
  145.       * 
  146.       * You should use this method for boopsi gadget objects,
  147.       * or for "models" which propagate information to gadgets.
  148.       *
  149.       * The object does whatever it wants with the message you sent,
  150.       * which might include updating its gadget visuals.
  151.       *
  152.       * The return value is defined per-method.
  153.       "
  154.       ^ <primitive 238 12 gadObj winObj reqObj msgObj>
  155. |      
  156.    translateBoopsiErrorNumber  
  157.       ^ <primitive 238 13>
  158. ]
  159.  
  160. " ------------------------------------------------------------------- "
  161. " BoopsiClassNames Class is a Singleton class that allows the user to "
  162. " reference BOOPSI Class name Strings as Symbols.                     "
  163. ""
  164. " The User does NOT need to create one of these, since Intuition      "
  165. " Class will instantiate the only needed instance of this Class.  See "
  166. " the SetupIntuition.st source file for the method(s) that help the   "
  167. " User with this Class.                                               "
  168. ""
  169. " ALL singleton classes MUST contain the following:                   "
  170. ""
  171. "   the methods:  isSingleton AND privateSetup     AND                "
  172. "                 uniqueInstance Class instance variable.             "
  173. " ------------------------------------------------------------------- "
  174.  
  175. Class BoopsiClassNames :Dictionary ! uniqueInstance !
  176. [
  177.    isSingleton
  178.      ^ true  
  179. |  
  180.    privateNew ! newInstance !
  181.      newInstance <- super new.
  182.      ^ newInstance
  183. |
  184.    new
  185.      ^ (self privateSetup)
  186. |
  187.    privateSetup
  188.      (uniqueInstance isNil)
  189.        ifTrue: [uniqueInstance  <- self privateNew.
  190.  
  191.                 self privateSetupDictionary.
  192.                ].
  193.                
  194.      ^ self
  195. |
  196.    privateSetupDictionary     
  197.  
  198.      " Class id strings for Intuition classes.  There's no real 
  199.      * reason to use the uppercase constants over the lowercase 
  200.      * strings, but this makes a good place to list the names of
  201.      * the built-in (BOOPSI) classes:
  202.      "
  203.      self at: #ROOTCLASS     put: 'rootclass'.     " classusr.h      "
  204.      self at: #IMAGECLASS    put: 'imageclass'.    " imageclass.h "
  205.      self at: #FRAMEICLASS   put: 'frameiclass'.
  206.      self at: #SYSICLASS     put: 'sysiclass'.
  207.      self at: #FILLRECTCLASS put: 'fillrectclass'.
  208.      self at: #GADGETCLASS   put: 'gadgetclass'.   " gadgetclass.h "
  209.      self at: #PROPGCLASS    put: 'propgclass'.
  210.      self at: #STRGCLASS     put: 'strgclass'.
  211.      self at: #BUTTONGCLASS  put: 'buttongclass'.
  212.      self at: #FRBUTTONCLASS put: 'frbuttonclass'.
  213.      self at: #GROUPGCLASS   put: 'groupgclass'.
  214.      self at: #ICCLASS       put: 'icclass'.       " icclass.h "
  215.      self at: #MODELCLASS    put: 'modelclass'.
  216.      self at: #ITEXTICLASS   put: 'itexticlass'.
  217.      self at: #POINTERCLASS  put: 'pointerclass'.  " pointerclass.h "
  218. ]
  219.